package com.weakteam.androidclient.data.domain;

import org.json.simple.JSONObject;

/**
 * @author Nail
 */
public class Goods {

    private Integer id;
    private Double price;
    private String name;
    private String description;
    private String ico;
    private String image;
    private String properties;

    public Integer getId() {
        return id;
    }

    public Double getPrice() {
        return price;
    }

    public String getName() {
        return name;
    }

    public String getDescription() {
        return description;
    }

    public String getIco() {
        return ico;
    }

    public String getImage() {
        return image;
    }

    public String getProperties() {
        return properties;
    }

    public Goods(JSONObject jGoods) {
        Object obj = null;

        obj = jGoods.get("id");
        if (obj != null) {
            this.id = ((Long)obj).intValue();
        }
        obj = jGoods.get("price");
        if (obj != null) {
            if (obj instanceof Double) {
                this.price = (Double)obj;
            } else if (obj instanceof Long) {
                this.price = ((Long)obj).doubleValue();
            }
        }

        obj = jGoods.get("name");
        if (obj != null) {
            this.name = (String)obj;
        }

        obj = jGoods.get("description");
        if (obj != null) {
            this.description = (String)obj;
        }

        obj = jGoods.get("ico");
        if (obj != null) {
            this.ico = (String)obj;
        }

        obj = jGoods.get("image");
        if (obj != null) {
            this.image = (String)obj;
        }

        obj = jGoods.get("properties");
        if (obj != null) {
            this.properties = (String)obj;
        }
    }

}
